home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / FIXEDM.ASM < prev    next >
Assembly Source File  |  1993-04-29  |  665b  |  26 lines

  1.         P386N
  2.  
  3. Dividend        EQU     dword ptr [bp+10]
  4. Divisor         EQU     dword ptr [bp+6]
  5.  
  6. _TEXT   SEGMENT BYTE USE16 PUBLIC 'CODE'
  7.         ASSUME  cs:_TEXT
  8.  
  9. PUBLIC  FixedDiv
  10. PROC    FixedDiv        FAR
  11.         push    bp
  12.         mov     bp,sp
  13.         mov edx,Dividend
  14.         sub eax,eax
  15.         shrd eax,edx,16         ; position so that result ends up
  16.         sar edx,16                  ;   in EAX
  17.         idiv Divisor
  18.         shld edx,eax,16              ; whole part of result in DX
  19.                                         ;   fractional part is already in AX
  20.         pop     bp
  21.         ret
  22. ENDP    FixedDiv
  23.  
  24. _TEXT   ENDS
  25.  
  26. END